<template>
  <div class="pie-box">
    <div class="pie-boxs">
      <!-- <div class="money">
        估值： <span>{{ money }}</span
        >(万元)
      </div> -->
      <!-- 专利指数 -->
      <div class="center-wrap">
        <div class="center-box">
          <ul id="clock" class="clock">
            <li
              v-for="(item, index) in liNumber"
              :key="index"
              :class="{ active: index < Math.ceil((j / 100) * liNumber) }"
              :style="{ transform: `rotate(${Number(index) * 10}deg)` }"
            ></li>
          </ul>
          <p class="number">
            <span>专利指数</span>
            <i>{{ j }}</i>
          </p>
        </div>
      </div>
      <el-progress
        v-if="percentage"
        type="circle"
        :percentage="percentage"
        :show-text="false"
        :width="175"
        color="#2f41c8"
      ></el-progress>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    j: {
      type: String
    },
    data: {
      type: Object
    },
  },
  data() {
    return {
      chart: null,
      liNumber: 36,
      percentage: 0,
      money: "",
    };
  },
  methods: {
    getMoney() {
      if (this.data && this.data.money && Object.keys(this.data).length > 0) {
        let dataMoney = JSON.parse(JSON.stringify(this.data.money));
        let money = (dataMoney / 10000).toFixed(2);
        this.money = money;
      }
    },
  },
  watch: {
    j (val) {
      this.percentage = val !== '' ? Number(this.j) : 0
    },
    data() {
      this.getMoney();
    },
  },
  mounted() {
    this.getMoney();
  },
  beforeDestroy() {
    if (!this.chart) {
      return;
    }
    this.chart.dispose();
    this.chart = null;
  },
};
</script>

<style lang="scss" scoped>
::v-deep .el-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-53%, -50%);
}
.pie-box {
  position: relative;
  top: 10px;
  right: 0;
  z-index: 2;
  width: 360px;
  height: 303px;
  padding-right: 20px;
  padding-left: 6px;
  box-sizing: border-box;
  .pie-boxs {
    background-color: $color78;
    width: 100%;
    height: 100%;
    float: right;
  }
  .money {
    line-height: 30px;
    box-sizing: border-box;
    padding: 0 14px;
    border-radius: 4px;
    margin: 10px;
    text-align: left;
    font-size: 12px;
    color: $mainColor;
    background-color: $color50;
    float: right;
    span {
      font-size: 20px;
      font-weight: 700;
    }
    &::after {
      content: "";
      clear: both;
    }
  }
  .center-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    // transform: translateY(-53px);
  }
  .center-box {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto;
    .clock {
      position: relative;
      width: 100%;
      height: 100%;
      list-style: none;
      li {
        position: absolute;
        top: 0%;
        left: 50%;
        width: 4px;
        height: 10px;
        background-color: $color76;
        transform-origin: 0 50px;
        &.active {
          background-color: $color49;
        }
      }
    }
    .number {
      position: absolute;
      top: 50%;
      left: 0;
      width: 100%;
      height: 100px;
      margin-top: -50px;
      text-align: center;
      span {
        display: inline-block;
        width: 100%;
        padding-top: 20px;
        font-weight: bold;
        font-size: 14px;
        letter-spacing: 1px;
        color: #4f515b;
      }
      i {
        display: inline-block;
        width: 100%;
        font-weight: bold;
        font-size: 36px;
        color: #504da6;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
  .outside-box {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 212px;
    height: 212px;
    border-radius: 50%;
    margin-top: -106px;
    margin-left: -106px;
    .elprogress {
      transform: rotate(-10deg);
    }
  }
}
</style>